/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ws
 * Date: 2022-11-11
 * Time: 22:27
 */
//public class Student{
//    public String name;
//    public String gender;
//    public int age;
//    public double score;
//    public static String classRoom = "Java";
//
//    public static String getClassRoom() {
//        return classRoom;
//    }
//    public void DoClass(){
//        System.out.println("asdfas");
//    }
//
//    public Student(String name, String gender, int age, double score) {
//        this.name = name;
//        this.gender = gender;
//        this.age = age;
//        this.score = score;
//    }
//
//    public static void main(String[] args) {
//        // 静态成员变量可以直接通过类名访问
//        System.out.println(Student.classRoom);
//        Student s1 = new Student("Li leilei", "男", 18, 3.8);
//        Student s2 = new Student("Han MeiMei", "女", 19, 4.0);
//        Student s3 = new Student("Jim", "男", 18, 2.6);
//        //类名访问
//        System.out.println(Student.classRoom);
//        // 也可以通过对象访问：但是classRoom是三个对象共享的
//        System.out.println(s1.classRoom);
//        System.out.println(s2.classRoom);
//        System.out.println(s3.classRoom);
//        System.out.println(s1.getClassRoom());
//    }
//}

public class Student{
    private String name;
    private String gender;
    private int age;
    private double score;
    private static String classRoom;
    //实例代码块
    {
        this.name = "bit";
        this.age = 12;
        this.gender = "man";
        System.out.println("I am instance init()!");
    }
    // 静态代码块
    static {
        classRoom = "bit306";
        System.out.println("I am static init()!");
    }
    public Student(){
        System.out.println("I am Student init()!");
    }
    //A只能在Student内部使用
    class A{
        public void B(){
            System.out.println("1111");
        }
    }
    static class InS{
        public void in(){
            System.out.println("5466");
        }
    }
    public static void main(String[] args) {
        //内部类调用
        Student.InS a = new Student.InS();
        a.in();
//        //无法创建对象
//        Student.A b = new Student.A();
//        b.B();

        System.out.println();
        Student s1 = new Student();
        Student s2 = new Student();
        //输出结果
        //只要new了，就执行,无论有多少对象，仅执行一次,之后不再执行
//        I am static init()! 静态代码块
        //s1
//        I am instance init()! 实例代码块
//        I am Student init()! 构造函数
        //s2
//        I am instance init()! 实例代码块
//        I am Student init()! 构造函数
    }
}



